package br.com.registrofinancas.adapters;

import br.com.registrofinancas.R;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CalendarioHeaderAdapter extends BaseAdapter {
	private Context contexto;
	private String[] dias;
	
	public CalendarioHeaderAdapter(Context contexto, String[] dias) {
		this.contexto = contexto;
		this.dias = dias;
	}
	public int getCount() {
		return dias.length;
	}

	@Override
	public Object getItem(int position) {
		return dias[position];
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@SuppressLint("InflateParams")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		TextView texto;
		if(null == convertView){
			LayoutInflater layout = ( LayoutInflater ) contexto.getSystemService( Context.LAYOUT_INFLATER_SERVICE ) ;
			convertView = layout.inflate(R.layout.activity_calendar_item, null);
			texto = (TextView) convertView.findViewById(R.id.activity_calendar_item_tv_dia_calendario);
			convertView.setTag(texto);
		}else{
			texto = (TextView) convertView.getTag(); 
		}
		texto.setTextSize(12);
		texto.setText(dias[position].toUpperCase());
		convertView.setBackground(contexto.getResources().getDrawable(R.drawable.calendar_cell));
		return convertView;
	}

}
